Imports [lib].myDBconn2
Imports System.Text

Namespace persistent

    Public Class CcChangeHist
        Public Shared Function GetHist(ByVal oldCustCode As String, ByVal newCustCode As String) As DataTable

            Dim _oldCustCode As String = oldCustCode
            Dim _newCustCode As String = newCustCode

            If oldCustCode = "" Then
                _oldCustCode = "NULL"
            End If

            If newCustCode = "" Then
                _newCustCode = "NULL"
            End If

            Dim query As String = "select h.old_custcode, h.new_custcode  " & _
                        vbNewLine & "from eu_bill.custcode_change_hist h " & _
                        vbNewLine & "where h.old_custcode = DECODE('" & _oldCustCode & "','NULL',h.old_custcode,'" & _oldCustCode & "')" & _
                        vbNewLine & "  and h.new_custcode = DECODE('" & _newCustCode & "','NULL',h.new_custcode,'" & _newCustCode & "')"

            'Return persistent.myDBConn.myORATable(query)
            'LOGLAMA
            Dim gen As Object = New Web.page.CcChangeHist()
            Return persistent.myDBConn.myORATable_LOG(query, _newCustCode, "null", "null", "null", "SELECT(CustcodeChangeHist)", "CcChangeHist", gen.session("user"))

        End Function

        Public Shared Function AddHist(ByVal oldCustCode As String, ByVal newCustCode As String, ByRef resultMessage As String) As Boolean
            Dim result1 As Boolean = False

            Try

                If oldCustCode = Nothing Then
                    Throw New Exception(String.Format("Old Customer Code bos olamaz!", oldCustCode))
                End If

                If newCustCode = Nothing Then
                    Throw New Exception(String.Format("New Customer Code bos olamaz!", oldCustCode))
                End If

                'persistent.myDBConn.ORAProcedure("eu_bill.custcode_change_hist_dml.i_CustCodeChangeHist", New String() {"pis_OldCustCode", "pis_NewCustCode"}, _
                '    New String() {oldCustCode, newCustCode})
                'LOGLAMA
                Dim gen As Object = New Web.page.CcChangeHist()
                persistent.myDBConn.ORAProcedure_LOG("eu_bill.custcode_change_hist_dml.i_CustCodeChangeHist", New String() {"pis_OldCustCode", "pis_NewCustCode"},
                                                                                        New String() {oldCustCode, newCustCode}, newCustCode, "null", "null", "null", "CALL PROCEDURE", "CcChangeHist", gen.session("user"))

                Return True

            Catch ex As Exception
                resultMessage = ex.Message
            End Try
            Return result1
        End Function

        Public Shared Function DeleteHist(ByVal oldCustCode As String, ByRef resultMessage As String) As Boolean
            Dim result1 As Boolean = False

            Try

                persistent.myDBConn.ORAProcedure("eu_bill.custcode_change_hist_dml.d_CustCodeChangeHist", _
                              New String() {"pis_OldCustCode"}, New String() {oldCustCode})
                'LOGLAMA
                Dim gen As Object = New Web.page.CcChangeHist()
                persistent.myDBConn.ORAProcedure_LOG("eu_bill.custcode_change_hist_dml.d_CustCodeChangeHist", _
                             New String() {"pis_OldCustCode"}, New String() {oldCustCode}, oldCustCode, "null", "null", "null", "CALL PROCEDURE", "CcChangeHist", gen.session("user"))
                Return True

            Catch ex As Exception
                resultMessage = ex.Message
            End Try
            Return result1
        End Function

        Public Shared Function UpdateHist(ByVal oldCustCode As String, ByVal newCustCode As String, ByVal OldOldCustCode As String, ByVal OldNewCustCode As String, ByRef resultMessage As String) As Boolean
            Dim result1 As Boolean = False

            Try
                '  persistent.myDBConn.ORAProcedure("eu_bill.custcode_change_hist_dml.u_CustCodeChangeHist", _
                '             New String() {"pis_OldCustCode", "pis_NewCustCode", "pis_OldOldCustCode", "pis_OldNewCustCode"}, New String() {oldCustCode, newCustCode, OldOldCustCode, OldNewCustCode})
                'LOGLAMA
                Dim gen As Object = New Web.page.CcChangeHist()
                persistent.myDBConn.ORAProcedure_LOG("eu_bill.custcode_change_hist_dml.u_CustCodeChangeHist", _
                          New String() {"pis_OldCustCode", "pis_NewCustCode", "pis_OldOldCustCode", "pis_OldNewCustCode"}, New String() {oldCustCode, newCustCode, OldOldCustCode, OldNewCustCode}, _
                          "null", "null", "null", "null", "CALL PROCEDURE", "CcChangeHist", gen.session("user"))

                Return True

            Catch ex As Exception
                resultMessage = ex.Message
            End Try

            Return result1

        End Function

        Public Shared Function CheckCustCode(ByVal CustCode As String, ByVal csType As String, ByRef resultMessage As String) As Integer
            Dim result1 As Integer

            Try
                ' result1 = persistent.myDBConn.ORAFunction("eu_bill.custcode_change_hist_dml.check_custcode", _
                '                               New String() {"pis_custcode", "pis_cstype"}, _
                '                              New String() {CustCode, csType})
                'LOGLAMA
                Dim gen As Object = New Web.page.CcChangeHist()
                result1 = persistent.myDBConn.ORAFunction_LOG("eu_bill.custcode_change_hist_dml.check_custcode", _
                                New String() {"pis_custcode", "pis_cstype"}, _
                                New String() {CustCode, csType}, CustCode, "null", "null", "null", "CALL FUNCTION", "CcChangeHist", gen.session("user"))
                Return result1
            Catch ex As Exception
                resultMessage = ex.Message
            End Try
        End Function
        Public Shared Function CheckOldCustCode(ByVal OldCustCode As String, ByRef resultMessage As String) As Integer
            Dim result1 As Integer

            Try
                ' result1 = persistent.myDBConn.ORAFunction("eu_bill.custcode_change_hist_dml.check_oldcustcode", _
                '                                New String() {"pis_oldcustcode"}, _
                '                               New String() {OldCustCode})
                'LOGLAMA
                Dim gen As Object = New Web.page.CcChangeHist()
                result1 = persistent.myDBConn.ORAFunction_LOG("eu_bill.custcode_change_hist_dml.check_oldcustcode", _
                                New String() {"pis_oldcustcode"}, _
                                New String() {OldCustCode}, _
                                OldCustCode, "null", "null", "null", "CALL FUNCTION", "CcChangeHist", gen.session("user"))
                Return result1
            Catch ex As Exception
                resultMessage = ex.Message
            End Try
        End Function
        Public Shared Function CheckNewCustCode(ByVal NewCustCode As String, ByRef resultMessage As String) As Integer
            Dim result1 As Integer

            Try
                'result1 = persistent.myDBConn.ORAFunction("eu_bill.custcode_change_hist_dml.check_newcustcode", _
                '                               New String() {"pis_newcustcode"}, _
                '                              New String() {NewCustCode})
                'LOGLAMA
                Dim gen As Object = New Web.page.CcChangeHist()
                result1 = persistent.myDBConn.ORAFunction_LOG("eu_bill.custcode_change_hist_dml.check_newcustcode", _
                                New String() {"pis_newcustcode"}, _
                                New String() {NewCustCode}, _
                                NewCustCode, "null", "null", "null", "CALL FUNCTION", "CcChangeHist", gen.session("user"))
                Return result1
            Catch ex As Exception
                resultMessage = ex.Message
            End Try
        End Function
    End Class
End Namespace
